package com.atguigu.day15.string01.s2;

import org.junit.Test;

import java.util.Arrays;

public class StringMethod01 {
    @Test
    public void test01() {
        //判断是否为空
        String s = "";
        boolean empty = s.isEmpty();
        System.out.println("empty = " + empty);
        String s1 = null;
        System.out.println("s1.isEmpty() = " + s1.isEmpty());
    }

    @Test
    public void test02() {
        //字符数量
        String s = "ABC,D EF";
        int length = s.length();
        System.out.println("length = " + length);
    }

    @Test
    public void test03() {
        //转大小写
        String s = "HELLOworld你好世界";

        String lowerCase = s.toLowerCase();
        System.out.println("lowerCase = " + lowerCase);//helloworld你好世界

        String upperCase = s.toUpperCase();
        System.out.println("upperCase = " + upperCase);//HELLOWORLD你好世界

        System.out.println("s = " + s);

    }

    @Test
    public void test04() {
        //拼接
        String s = "安琪拉";
        String s1 = "赵丽颖";
        String concat = s.concat(s1);
        System.out.println("concat = " + concat);//安琪拉赵丽颖
    }
    @Test
    public void test05(){
        String s1 = new String("HelloWorld");
        String s2 = "HelloWorld";

        System.out.println(s1==s2);//false

        boolean equals = s1.equals(s2);
        System.out.println("equals = " + equals);

    }
    @Test
    public void test06(){
        //忽略大小写比较内容
        String s1 = "HELLO";
        String s2 = "hello";
        boolean equals = s1.equalsIgnoreCase(s2);
        System.out.println("equals = " + equals);
    }
    @Test
    public void test07(){
        //比较内容大小 从下标0开始挨个比较
       String s1= "ABC";
       String s2 = "AD";

        int compare = s1.compareTo(s2);
        System.out.println("compare = " + compare);

        String s3 = "abc";
        String s4 = "ABC";


        int compare1 = s3.compareToIgnoreCase(s4);
        System.out.println("compare1 = " + compare1);
    }
    @Test
    public void test08(){
        //去除两端的空白
        String s = "   A  B  C   ";
        System.out.println("---->"+s+"<------");
        String trim = s.trim();
        System.out.println("---->"+trim+"<------");
    }
    @Test
    public void test09(){
       // String s = "A1B1C1D";
        //  String[] array = s.split("1");
      /*  String s = "ABCD";
        String[] array = s.split("");*/
        String s = "A,1,B,2,C,3,D";
        //\d:匹配数字
        String[] array = s.split(",");

        System.out.println(array[0]);
        System.out.println(array.length);
        System.out.println(Arrays.toString(array));


    }

}
